package cn.xgx.mapper;

import cn.xgx.model.User;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;
import org.mapstruct.Mapper;
import org.springframework.stereotype.Repository;

@Repository
@Mapper
public interface UserMapper extends BaseMapper<User> {

    @Select("select count(1) from sys_user where username=#{username} and password=#{password}")
    int findByUsernameAndPassword(String username,String password);

    @Select("select * from sys_user where username=#{username}")
    User findByUsername(String username);

    @Select("select count(1) from sys_user where username=#{username}")
    int countByUsername(String username);

    @Select("select count(1) from sys_user where username=#{username} and id!=#{id}")
    int countByUsernameAndNotId(String username,long id);
}
